$(function(){
    let product = document.querySelector("#product>.info")
    let str = "";
    fetch("http://chst.vip:1234/api/getinlanddiscount")
    .then(body=>body.json())
    .then(res=>{
        
        res.result.forEach(item => {
            
            let regExp = /(\/|http)[^>]+\.(jpg|jpeg|png|gif)/g
            let r = item.productImg.match(regExp)
            
            str+=`<li productid=${item.productId}>
                    <a href="#">
                    <div class="image"><img src="${r[0]}"></div>
                    <div class="title">${item.productName}</div>
                    <p class="price">${item.productPrice}</p>
                    <p class="from">${item.productFrom}|${item.productTime}</p>
                    </a>
                </li>`
            
        });
        product.innerHTML=str;
        
        
        let uli = document.querySelectorAll("li")
        console.log(uli);
        for(var i=0;i<uli.length;i++){
            uli[i].onclick=function(){
                let id=this.getAttribute('productid')
                console.log(id)
                location.href='./discountDetails.html?productId='+id
            }
        }
        
    })
    

})